package tienmanh.gs.goldminer.util;

import java.util.ArrayList;

import tienmanh.gs.goldminer.manager.ResourcesManager;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class Star {
	public static String filename = "star";
	public static SharedPreferences sp;
	public static Editor edit;
	public static ArrayList<String> nameStar = new ArrayList<String>();
	public static ArrayList<Integer> numberStar = new ArrayList<Integer>();
	
	public static void init(){
		sp = ResourcesManager.getInstance().activity.getSharedPreferences(filename,0);
		edit = sp.edit();
		for (int i = 0; i < 30; i++) {
			nameStar.add("star"+(i+1));
		}
	}
	public static void writeStarSP(int star , int value){
		edit.putInt(nameStar.get(star), value);
	    edit.commit();
	}
	public static int readStarSP(int star){
	    return sp.getInt(nameStar.get(star), 0);
	}
	public static ArrayList<Integer> readAllStarSP(){
		for (int i = 0; i < numberStar.size(); i++) {
			numberStar.add(sp.getInt(nameStar.get(i), 0));
		}
		return numberStar;
	}
	public static int numberStar(){
		int value = 0;
		for (int i = 0; i < numberStar.size(); i++) {
				value += numberStar.get(i);
		}
		return value;
	}
}
